#!/bin/csh -f

###########################################################################
# 02/05/93 James Created - get machine type using file/hinv/uname.
# 02/12/93 James check for sun/solaris.
# 03/01/93 James Fix for nec_risc r4000
# 04/05/93 Pete  added alpha_unix
# 04/17/93 James Removed quotes around hinv_out.
# 06/21/93 jmichaud Allow for IRIX 5.0 sgi and sgi_r4k (ELF 32-bit).
# 08/27/93 James sun4_solaris.
# 11/17/93 James R4000->R4..0
# 11/19/93 James IBM PowerPC fix.
# 12/08/93 $$1 James hitachi.
# 04/26/94 $$2 James handle jap sgi.
# 05/16/95 $$3 Pete  set LANG C at top, all platforms work well with this
# 06/22/95 $$4 true R4..0->R[48]..0 to allow for SGI R8000 systems.
# 11/27/95 $$5 Pete  added sgi_elf2 for 5.3 and beyond
# 02/01/96 $$6 Pete  added R5000 support for sgi (for Tom True)
# 18-Jun-96 Pete   $$7  revised by Joe Michaud and tweaked by me
# 20-Jun-96 Pete   $$8  fixed bug in previous subm comment block
# 05-Dec-96 Pete   $$9  added hp8k
# 30-Dec-96 Jane   $$10 distinguish hp700 and hp8k properly
# 08-Sep-97 JJE    $$11 Just hp8k now for 19
# 27-Mar-98 jmichaud $$12 added sgi_mips4
# 08-Mar-00 MAZ           Get rid of env os_name
# 04-Aug-00 TWH      $$13 Add hpux11_pa32
# 01-Dec-00 TWH      $$14 Add sun4_solaris_64
# 16-May-01 TWH      $$15 Add hpux_pa64
# 15-Jul-01 MAZ      $$16 Introduce FORCE_PMT
###########################################################################

setenv LANG C

set id = "UNKNOWN"

switch (`uname -s`)
    case "IRIX":
    case "IRIX64":
        set cpu = (`hinv -t cpu`)
        if ("`expr $cpu[3] : 'R[23]*'`" > "1") then
            # Not supported.
        else if ("`expr $cpu[3] : 'R4*'`" > "1") then
            set id = "sgi_elf2"
        else
            set id = "sgi_mips4"
        endif
    breaksw

    case "OSF1":
        set id = "alpha_unix"
    breaksw

    case "HP-UX":
        set rev = `uname -r`
        if ("`expr $rev : '[A-Z].11.*'`" > "1") then
	  if ("`file /stand/vmunix | grep 'ELF-64'`" == "") then
            set id = "hpux11_pa32"
          else
            set id = "hpux_pa64"
          endif
        else
            set id = "hp8k"
        endif
    breaksw

    case "AIX":
        set id = "ibm_rs6000"
    breaksw

    case "SunOS":
        set rev = `isalist |grep sparcv9 | wc -c`
        if ("$rev" > "0") then
	   set id = "sun4_solaris_64"
        else
           set id = "sun4_solaris"
        endif
    breaksw

    case "HI-UX":
        set id = "hitachi"
    breaksw

    case "UNIX_SV":
        set id = "nec_mips"
    breaksw
endsw

if( $?FORCE_PMT ) then
    echo $FORCE_PMT 
else
    echo $id 
endif

